<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.ama.pojo.Property" %>
<%@ page import="java.math.BigInteger" %>
<%@ page import="com.ama.service.PropertyService" %>
<%@ page import="com.ama.utils.SpringUtils" %>
<%@ page import="com.ama.service.impl.PropertyServiceImpl" %>
<%@ page import="com.ama.service.StaffService" %>
<%@ page import="com.ama.pojo.Staff" %>
<%@ page import="com.ama.service.impl.StaffServiceImpl" %>
<%@ page import="java.util.List" %>
<%@ page import="com.ama.service.EstateService" %>
<%@ page import="com.ama.service.impl.EstateServiceImpl" %>
<%@ page import="com.ama.pojo.Estate" %>
<%@ page import="com.ama.service.BuildService" %>
<%@ page import="com.ama.service.impl.BuildServiceImpl" %>
<%@ page import="com.ama.pojo.Build" %>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <title>楼栋管理</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="author" content="">
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/materialdesignicons.min.css" rel="stylesheet">
    <link href="../css/animate.css" rel="stylesheet">
    <link href="../css/style.min.css" rel="stylesheet">
    <link href="../js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
</head>

<%
    Long estateId = Long.valueOf(request.getParameter("estate"));
    Estate estate = SpringUtils.getBean(EstateServiceImpl.class).selectById(estateId);
    BuildService buildService = SpringUtils.getBean(BuildServiceImpl.class);
    List<Build> builds = buildService.selectByEstateId(estateId);
%>

<body>
<div class="container-fluid p-t-15">

    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">

                    <div class="container-fluid p-t-15">
                        <div class="row">
                            <div class="col-lg-12">
                                <div class="card">
                                    <div class="card-header"><h4>楼房信息</h4></div>
                                    <div class="card-body">

                                        <form name="build_form" method="post" class="guide-box"
                                              data-navigateable="true">
                                            <ul class="nav-step step-dots">
                                                <li class="nav-step-item active">
                                                    <span>小区</span>
                                                    <a class="" data-toggle="tab" href="#step-1"></a>
                                                </li>

                                                <li class="nav-step-item active">
                                                    <span>楼栋</span>
                                                    <a class="active" data-toggle="tab" href="#step-2"></a>
                                                </li>

                                                <li class="nav-step-item ">
                                                    <span>房屋</span>
                                                    <a data-toggle="tab" href="#step-3"></a>
                                                </li>
                                            </ul>
                                            <hr>
                                            <!--对应内容-->
                                            <div class="nav-step-content">
                                                <div class="fixed-table-container" style="padding-bottom: 0px;">
                                                    <div class="fixed-table-header" style="display: none;">
                                                        <table></table>
                                                    </div>
                                                    <div class="fixed-table-body">
                                                        <div class="fixed-table-loading table table-bordered table-hover table-striped"
                                                             style="top: 44px; display: none;">
                                                            <span class="loading-wrap">
                                                            <span class="loading-text">正在努力地加载数据中，请稍候</span>
                                                            <span class="animation-wrap"><span
                                                                    class="animation-dot"></span></span>
                                                            </span>
                                                        </div>
                                                        <table id=""
                                                               class="table table-bordered table-hover table-striped">
                                                            <thead class="">
                                                            <tr>
                                                                <th class="bs-checkbox " style="width: 36px; "
                                                                    data-field="0">
                                                                    <div class="th-inner "><label
                                                                            class="lyear-radio radio-primary"></label>
                                                                    </div>
                                                                </th>
                                                                <th style="" data-field="id">
                                                                    <div class="th-inner sortable both">ID</div>
                                                                    <div class="fht-cell"></div>
                                                                </th>
                                                                <th style="" data-field="author">
                                                                    <div class="th-inner ">小区编号</div>
                                                                    <div class="fht-cell"></div>
                                                                </th>

                                                                <th style="" data-field="nationality">
                                                                    <div class="th-inner ">楼栋编号</div>
                                                                    <div class="fht-cell"></div>
                                                                </th>
                                                                <th style="" data-field="status">
                                                                    <div class="th-inner ">楼栋名称</div>
                                                                    <div class="fht-cell"></div>
                                                                </th>
                                                                <th style="" data-field="status">
                                                                    <div class="th-inner ">房东</div>
                                                                    <div class="fht-cell"></div>
                                                                </th>

                                                                <th style="" data-field="operate">
                                                                    <div class="th-inner ">楼栋地址</div>
                                                                    <div class="fht-cell"></div>
                                                                </th>
                                                                <th style="" data-field="operate">
                                                                    <div class="th-inner ">楼栋层数</div>
                                                                    <div class="fht-cell"></div>
                                                                </th>
                                                                <th style="" data-field="operate">
                                                                    <div class="th-inner ">可用面积</div>
                                                                    <div class="fht-cell"></div>
                                                                </th>
                                                                <th style="" data-field="operate">
                                                                    <div class="th-inner ">使用期限</div>
                                                                    <div class="fht-cell"></div>
                                                                </th>
                                                                <th style="" data-field="operate">
                                                                    <div class="th-inner ">剩余期限</div>
                                                                    <div class="fht-cell"></div>
                                                                </th>
                                                                <th style="" data-field="operate">
                                                                    <div class="th-inner ">楼栋状态</div>
                                                                    <div class="fht-cell"></div>
                                                                </th>

                                                                <th style="" data-field="status">
                                                                    <div class="th-inner ">启用状态</div>
                                                                    <div class="fht-cell"></div>
                                                                </th>

                                                                <th style="" data-field="operate">
                                                                    <div class="th-inner ">操作</div>
                                                                    <div class="fht-cell"></div>
                                                                </th>


                                                            </tr>
                                                            </thead>

                                                            <tbody>
                                                            <%
                                                                int status = 1;
                                                                for (Build build : builds) {
                                                            %>
                                                            <tr class="">
                                                                <td class="bs-checkbox ">
                                                                    <label class=" lyear-radio radio-primary ">
                                                                        <input data-index="0" name="build" type="radio"
                                                                               <% if(status==1){%>checked<%}%>
                                                                               value="<%=build.getBuildId()%>">
                                                                        <span></span>
                                                                    </label></td>
                                                                <td style=""><%=status%>
                                                                </td>
                                                                <td style=""><%=build.getEstateId()%>
                                                                </td>

                                                                <td style=""><%=build.getBuildId()%>
                                                                </td>
                                                                <td style=""><%=build.getBuildName()%>
                                                                </td>
                                                                <td style=""><%=build.getBuildOwner()%>
                                                                </td>
                                                                <td style=""><%=build.getBuildAddress()%>
                                                                </td>
                                                                <td style=""><%=build.getBuildFloornum()%>
                                                                </td>
                                                                <td style=""><%=build.getBuildUsearea()%>㎡
                                                                </td>
                                                                <td style=""><%=build.getBuildUsetime()%>
                                                                </td>
                                                                <td style=""><%=build.getBuildLasttime()%>
                                                                </td>

                                                                <%if (build.getBuildState()==1){%>
                                                                <td style="">
                                                                    <a href="javascript:void(0)" data-name="status" data-pk="1"
                                                                       class="label label-success editable editable-click"
                                                                       data-value="1">空闲
                                                                    </a>
                                                                </td>
                                                                <%}else {%>
                                                                <td style="">
                                                                    <a href="javascript:void(0)" data-name="status" data-pk="1"
                                                                       class="label label-danger editable editable-click"
                                                                       data-value="1">无空位
                                                                    </a>
                                                                </td>
                                                                <%}%>

                                                                <%
                                                                    if(build.getBuildOpen()==1){
                                                                %>
                                                                <td style="">
                                                                    <a href="javascript:void(0)" data-name="status" data-pk="1"
                                                                       class="label label-success editable editable-click"
                                                                       data-value="1">启用
                                                                    </a>
                                                                </td>
                                                                <%
                                                                }else if(build.getBuildOpen()==-1){
                                                                %>
                                                                <td style="">
                                                                    <a href="javascript:void(0)" data-name="status" data-pk="1"
                                                                       class="label label-danger editable editable-click"
                                                                       data-value="1">禁用
                                                                    </a>
                                                                </td>
                                                                <%
                                                                    }
                                                                %>

                                                                <td style="">
                                                                    <a type="button" class="btn btn-default" href="p_roommanage.jsp?buildId=<%=build.getBuildId()%>">
                                                                        查看详情
                                                                    </a>
                                                                </td>
                                                            </tr>
                                                            </tr>

                                                            <% status++;
                                                            }%>

                                                            </tbody>

                                                        </table>
                                                    </div>
                                                    <div class="fixed-table-footer" style="display: none;">
                                                        <table>
                                                            <thead>
                                                            <tr></tr>
                                                            </thead>
                                                        </table>
                                                    </div>
                                                </div>

                                            </div>
                                            <!--End 对应内容-->
                                            <hr>
                                            <div class="nav-step-button m-b-10">
                                                <a type="button" class="btn btn-default" href="p_estatemanage.jsp">
                                                    上一步
                                                </a>
                                            </div>
                                            <input hidden name="estateId" value="<%=estateId%>">

                                            <script>
                                                function addBuild(){
                                                    document.build_form.action="p_addBuild.jsp";
                                                    document.build_form.submit();
                                                }
                                                function openBuild(){
                                                    document.build_form.action="/openBuild";
                                                    document.build_form.submit();
                                                }
                                                function ban(){
                                                    document.build_form.action="/banBuild";
                                                    document.build_form.submit();
                                                    console.log("ban");
                                                }
                                                function del(){
                                                    if (confirm("确认删除？")) {
                                                        document.build_form.action="/delBuild";
                                                        document.build_form.submit();
                                                    } else {
                                                    }
                                                }
                                            </script>

                                            <div id="toolbar" class="toolbar-btn-action">
                                                <a id="btn_add" type="button" onclick="addBuild()" class="btn btn-primary m-r-5">
                                                    <span class="mdi mdi-plus" aria-hidden="true"></span>新增
                                                </a>

                                                <a id="btn_open" type="button" onclick="openBuild()" class="btn btn-success m-r-5">
                                                    <span class="mdi mdi-check" aria-hidden="true"></span>启用
                                                </a>
                                                <a id="btn_ban" type="button" onclick="ban()" class="btn btn-warning m-r-5">
                                                    <span class="mdi mdi-block-helper" aria-hidden="true"></span>禁用
                                                </a>
                                                <a id="btn_del" type="button" onclick="del()" class="btn btn-danger">
                                                    <span class="mdi mdi-window-close" aria-hidden="true"></span>删除
                                                </a>
                                            </div>
                                        </form>

                                    </div>
                                </div>
                            </div>

                        </div>

                    </div>

                    <script type="text/javascript" src="../js/jquery.min.js"></script>
                    <script type="text/javascript" src="../js/bootstrap.min.js"></script>
                    <!--向导插件-->
                    <script type="text/javascript" src="../js/jquery.bootstrap.wizard.min.js"></script>

                    <!--对话框-->
                    <script src="../js/jconfirm/jquery-confirm.min.js"></script>
                    <script type="text/javascript" src="../js/main.min.js"></script>

                    <table id="tb_departments"></table>

                </div>
            </div>
        </div>


    </div>

</div>

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="js/bootstrap-table/bootstrap-table.min.js"></script>
<script type="text/javascript" src="js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>

<!--行内编辑插件-->
<link href="js/x-editable/1.5.1/bootstrap3-editable/css/bootstrap-editable.min.css" rel="stylesheet">
<script type="text/javascript" src="js/x-editable/1.5.1/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
<script type="text/javascript" src="js/bootstrap-table/extensions/editable/bootstrap-table-editable.min.js"></script>

<script type="text/javascript" src="js/main.min.js"></script>



</body>
</html>